package com.example.lib_net.api


import com.example.lib_net.constant.API
import com.example.lib_net.model.api.AfterSaleModel
import com.example.lib_net.model.api.BaseModel
import com.example.lib_net.model.api.ImgItem
import com.example.lib_net.model.api.LoginAuthModel
import com.example.lib_net.model.api.MineModel
import com.example.lib_net.model.api.PostCommentModel
import com.example.lib_net.model.api.PostItem
import com.example.lib_net.model.api.PostModel
import com.example.lib_net.model.api.ReportTypeModel
import com.example.lib_net.model.api.UpdateModel
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query

interface Api {
    /**
     * 判断版本是否需要更新
     */
    @GET(API.APP_LEVEL_CHECK)
    suspend fun appLevelCheck(@Query("platform") platform:String = "ANDROID"): BaseModel<UpdateModel>


    /**
     * 获得用户信息
     */
    @GET(API.APP_USER_INFO)
    suspend fun getUserInfo(): BaseModel<MineModel>

    /**
     * 登陆发送验证码接口
     */
    @POST(API.APP_LOGIN_SMS_CODE)
    @FormUrlEncoded
    suspend fun sendLoginCode(@Field("phone") phone:String,@Field("operatorType") operatorType:Int = 2):BaseModel<Boolean>

    /**
     * 验证码登陆校验
     */
    @POST(API.APP_LOGIN_AUTH)
    suspend fun loginAuth(@Body body:RequestBody):BaseModel<LoginAuthModel>
    /**
     * 忘记密码发送验证码接口
     */
    @POST(API.APP_RESET_SMS_CODE)
    @FormUrlEncoded
    suspend fun sendForgetPwdCode(@Field("phone") phone:String,@Field("operatorType") operatorType:Int = 2):BaseModel<Boolean>

    /**
     * 忘记密码验证码验证接口
     */
    @POST(API.APP_RESET_AUTH_SMS_CODE)
    suspend fun resetPwdAuth(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 绑定密码接口
     */
    @POST(API.APP_RESET_AUTH_SMS_CODE)
    suspend fun resetPwd(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 账号密码登陆
     */
    @POST(API.APP_LOGIN_AUTH)
    suspend fun login(@Body body:RequestBody):BaseModel<LoginAuthModel>


    /**
     * 帖子数据  category 0是帖子 2是热门
     */
    @GET(API.POST_PAGE)
    suspend fun getPostPage(@Query("category") category:Int?,@Query("pageNum") page:Int,@Query("pageSize") pageSize:Int):BaseModel<PostModel>

    /**
     * 校验帖子
     */
    @GET(API.POST_VALIDATION)
    suspend fun validatePost(@Query("postsId") postsId:String):BaseModel<Boolean>

    /**
     * 点赞和取消点赞
     */
    @GET(API.POST_LIKE_OR_CANCEL)
    suspend fun likeOrCancel(@Query("postsId") postsId:String):BaseModel<Boolean>
    /**
     * 收藏和取消收藏
     */
    @POST(API.POST_COLLECT_OR_CANCEL)
    suspend fun collectOrCancel(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 关注
     */
    @GET(API.FOLLOW_MEMBER)
    suspend fun followMember(@Query("memberId") memberId:String):BaseModel<Boolean>

    /**
     * 取消关注
     */
    @GET(API.FOLLOW_CANCEL_MEMBER)
    suspend fun followCancelMember(@Query("memberId") memberId:String):BaseModel<Boolean>

    /**
     * 屏蔽帖子
     */
    @POST(API.SHIELD_SAVE)
    suspend fun shieldSave(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 删除帖子
     */
    @GET(API.DELETE_POST)
    suspend fun deletePost(@Query("postsId") postsId:String):BaseModel<Boolean>

    /**
     * 举报类型列表
     */
    @GET(API.REPORT_TYPE_LIST)
    suspend fun reportTypeList():BaseModel<List<ReportTypeModel>>

    /**
     * 举报帖子
     */
    @POST(API.REPORT_POST)
    suspend fun reportPost(@Body body:RequestBody):BaseModel<Any>

    /**
     * 帖子详情
     */
    @GET(API.POST_DETAIL)
    suspend fun postDetail(@Query("postsId") postsId:String):BaseModel<PostItem>
    /**
     * 帖子售后信息
     */
    @GET(API.POST_AFTER_SALE)
    suspend fun postAfterSale(@Query("postsId") postsId:String,@Query("pageNum") pageNum:Int,@Query("pageSize") pageSize:Int):BaseModel<AfterSaleModel>
    /**
     * 获得帖子评论
     */
    @GET(API.POST_COMMENT)
    suspend fun postComment(@Query("postsId") postsId:String,@Query("pageNum") pageNum:Int,@Query("pageSize") pageSize:Int):BaseModel<PostCommentModel>
    /**
     * 评论校验帖子
     */
    @POST(API.POST_COMMENT_VALIDATION)
    suspend fun postCommentValidation(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 评论帖子
     */
    @POST(API.POST_COMMENT_SAVE)
    suspend fun postCommentSave(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 发布帖子
     */
    @POST(API.POST_PUBLISH)
    suspend fun postPublish(@Body body:RequestBody):BaseModel<Boolean>

    /**
     * 多文件上传
     */
    @POST(API.FILE_UPLOAD)
    @Multipart
    suspend fun fileUpload(@Part files:List<MultipartBody.Part>):BaseModel<List<ImgItem>>
}
